perm filename DVTMP[MF,ALS] blob sn#776772 filedate 1984-11-18 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	A \.{GF} file is a stream of 8-bit bytes that may be
C00017 ENDMK
C⊗;
A \.{GF} file is a stream of 8-bit bytes that may be
regarded as a series of commands in a machine-like language. The first
byte of each command is the operation code, and this code is followed by
zero or more bytes that provide parameters to the command. The parameters
themselves may consist of several consecutive bytes; for example, the
`|boc|' (beginning of character) command has seven parameters, each of
which is four bytes long. Parameters are usually regarded as nonnegative
integers; but four-byte-long parameters can be either positive or
negative, hence they range in value from $-2↑{31}$ to $2↑{31}-1$.
As in \.{TFM} files, numbers that occupy
more than one byte position appear in BigEndian order,
and negative numbers appear in two's complement notation.

A \.{GF} file consists of a ``preamble,'' followed by a sequence of one or
more ``characters,'' followed by a ``postamble.'' The preamble is simply a
|pre| command, with its parameters that introduce the file; this must come
first.  Each ``character'' consists of a |boc| command, followed by any
number of other commands that specify the ``black'' pixels of a character,
followed by an |eoc| command. The characters appear in the order that \MF\
generated them. If we ignore no-op commands (which are allowed between any
two commands in the file), each |eoc| command is immediately followed by a
|boc| command, or by a |post| command; in the latter case, there are no
more characters in the file, and the remaining bytes form the postamble.
Further details about the postamble will be explained later.

Some parameters in \.{GF} commands are ``pointers.'' These are four-byte
quantities that give the location number of some other byte in the file;
the first byte is number~0, then comes number~1, and so on.

@ The \.{GF} format is intended to be both compact and easily interpreted
by a machine. Compactness is achieved by making most of the information
relative instead of absolute. When a \.{GF}-reading program reads the
commands for a character, it keeps track of several quantities: (a)~the current
row number,~|y|; (b)~the current column number,~|x|; and (c)~the current
starting-column number,~|z|. These are 32-bit signed integers, although
most actual font formats produced from \.{GF} files will need to curtail
this vast range because of practical limitations. (\MF\ output will never
allow $\vert x\vert$, $\vert y\vert$, or $\vert z\vert$ to exceed 4095,
but the \.{GF} format tries to be more general.)

How do \.{GF}'s row and column numbers correspond to the conventions
of \TeX\ and \MF? Well, the ``reference point'' of a character, in \TeX's
view, is considered to be at the lower left corner of the pixel in row~0
and column~0. This point is the intersection of the baseline with the left
edge of the type; it corresponds to location $(0,0)$ in \MF\ programs.
Thus the pixel in row~0 and column~0 is \MF's unit square, comprising the
region of the plane whose coordinates both lie between 0 and~1. Negative
values of~|y| correspond to rows of pixels {\sl below\/} the baseline.

Besides |x|, |y|, and |z|, there's also a fourth aspect of the current
state, namely the @!|paint_switch|, which is always either \\{black} or
\\{white}. Each \\{paint} command advances |x| by a specified amount~|d|,
and blackens the intervening pixels if |paint_switch=black|; then
the |paint_switch| changes its state. \.{GF}'s commands are designed so
that |x| will never decrease within a row, and |y| will never increase
within a character; hence there is no way to whiten a pixel that has
been blackened.

As will be explained later,
this program makes use of yet another, but quite similar, abstracted
format to store
the \.{GF} information internally in the |store| array.  In this case,
it is possible
to achieve a still greater compression of the data and still meet the
needs for conveying font information to the \.{IMAGEN} printer.

@ Here is a list of all the commands that may appear in a \.{GF} file. Each
command is specified by its symbolic name (e.g., |boc|), its opcode byte
(e.g., 67), and its parameters (if any). The parameters are followed
by a bracketed number telling how many bytes they occupy; for example,
`|d[2]|' means that parameter |d| is two bytes long.

\yskip\hang|paint_0| 0. This is a \\{paint} command with |d=0|; it does
nothing but change the |paint_switch| from \\{black} to \\{white} or vice~versa.

\yskip\hang\\{paint\_1} through \\{paint\_63} (opcodes 1 to 63).
These are \\{paint} commands with |d=1| to~63, defined as follows: If
|paint_switch=black|, blacken |d|~pixels of the current row~|y|,
in columns |x| through |x+d-1| inclusive. Then, in any case,
complement the |paint_switch| and advance |x| by~|d|.

\yskip\hang|paint1| 64 |d[1]|. This is a \\{paint} command with a specified
value of~|d|; \MF\ uses it to paint when |64≤d<256|.

\yskip\hang|@!paint2| 65 |d[2]|. Same as |paint1|, but |d|~can be as high
as~65535.

\yskip\hang|@!paint3| 66 |d[3]|. Same as |paint1|, but |d|~can be as high
as $2↑{24}-1$. \MF\ never needs this command, and it is hard to imagine
anybody making practical use of it; surely a more compact encoding will be
desirable when characters can be this large. But the command is there,
anyway, just in case.

\yskip\hang|boc| 67 |c[4]| |p[4]| |min_x[4]| |max_x[4]| |min_y[4]|
|max_y[4]| |z[4]|. Beginning of a character:  Here |c| is the character
code, and |p| points to the previous |boc| command (if any) for characters
having this code number modulo 256.  (The pointer |p| is |-1| if there was
no prior character with an equivalent code.) All $x$-coordinates of black
pixels in the character that follows will be |≥min_x| and |≤max_x|; all
$y$-coordinates of black pixels will be |≥min_y| and |≤max_y|. Finally,
|z|~is the leftmost potentially black column in row |max_y|; it satisfies
|min_x≤z≤max_x|. When a \.{GF}-reading program sees a |boc|, it can use
|min_x|, |max_x|, |min_y|, and |max_y| to initialize the bounds of an
array. Then it sets |y←max_y|, |paint_switch←black|, and initializes its
|x| and |z| registers to the stated value of~|z|.

\yskip\hang|eoc| 68. End of character: All pixels blackened so far
constitute the pattern for this character. In particular, a completely
blank character might have |eoc| immediately following |boc|.

\yskip\hang|skip1| 69 |m[1]|. Decrease |y| by |m+1|, set |x←z|, and set
|paint_switch←black|. This is a way to produce |m| all-white rows.

\yskip\hang|@!skip2| 70 |m[2]|. Same as |skip1|, but |m| can be as large
as 65535.

\yskip\hang|@!skip3| 71 |m[3]|. Same as |skip1|, but |m| can be as large
as $2↑{24}-1$. \MF\ obviously never needs this command.

\yskip\hang|new_row| 72 |u[4]|. Decrease |y| by 1 and set |z←z+u|; then set
|x←z| and |paint_switch←black|. (It's a general way to finish one row
and begin another.)

\yskip\hang|@!left_z_83| through |@!left_z_1| (opcodes 73 to 155). Same as
|new_row|, with |u=-83| through |-1|, respectively.

\yskip\hang|right_z_0| 156. Same as |skip1| with |m=0| or |new_row| with
|u=0|.

\yskip\hang|@!right_z_1| through |@!right_z_83| (opcodes 157 to 239). Same as
|new_row|, with |u=+1| through |+83|, respectively. \MF\ generates a
|new_row| command only when $\vert u\vert>83$.

\yskip\hang|@!gf_nop| 240. No operation, do nothing. Any number of |gf_nop|'s
may occur between \.{GF} commands, but a |gf_nop| cannot be inserted between
a command and its parameters or between two parameters. This command is called
|gf_nop| when used in this program to avoid conflict with the use of |nop|
by \.{DVI} which uses it for code 138.

\yskip\hang|xxx1| 241 |k[1]| |x[k]|. This command is undefined in
general; it functions as a $(k+2)$-byte |nop| unless special \.{GF}-reading
programs are being used. \MF\ generates |xxx1| commands when encountering
a special string; this occurs in the \.{GF} file only between
characters, after the preamble, and before the postamble. However, \\{xxx}
commands can appear anywhere. It is recommended that |x| be a string
having the form of a keyword followed by possible parameters relevant to
that keyword. This command is called |gf_xxx1, again to avoid conflict.

\yskip\hang|@!xxx2| 242 |k[2]| |x[k]|.  Not used.

\yskip\hang|xxx3| 243 |k[3]| |x[k]|.  Not used.

\yskip\hang|xxx4| 244 |k[4]| |x[k]|.  Not used.

\yskip\hang|yyy| 245 |n[4]|. This command is undefined in general.
It acts as a 5-byte |nop| in this program.

\yskip\hang|char_loc| 246 |c[1]| |v[4]| |w[4]| |p[4]|.
This command will appear only in the postamble, which will be explained shortly.

\yskip\hang|pre| 247 |i[1]| |k[1]| |x[k]|.
Beginning of the preamble; this must come at the very beginning of the
file. Parameter |i| is an identifying number for GF format, currently
129. The other information is merely commentary; it is not given
special interpretation like \\{xxx} commands are. (Note that \\{xxx}
commands may immediately follow the preamble, before the first |boc|.)

\yskip\hang|post| 248. Beginning of the postamble, see below.

\yskip\hang|post_post| 249. Ending of the postamble, see below.

\yskip\noindent Commands 250--255 are undefined at the present time.